from sphinx.util import requests

spot_demo = {'instType': 'SWAP',
'instId': 'BTC-USDT-SWAP',
'uly': 'BTC-USDT',# 标的指数
'instFamily': 'BTC-USDT', # 交易品种
'baseCcy': '', # 合约没有这个字段
'quoteCcy': '', # 合约没有这个字段
'ctVal': '0.01', # 合约面值
'ctMult': '1', # 合约乘数
'ctValCcy': 'BTC', # 合约面值计价币种
'listTime': '1573557408000',
'openType': '', # 合约没有这个字段
 'expTime': '', # 产品下线时间
'tickSz': '0.1',
'lotSz': '0.01',
'minSz': '0.01',
'ctType': 'linear', # 合约类型,linear:正向合约,inverse：反向合约
'state': 'live',
'ruleType': 'normal',
'maxLmtSz': '100000000',
'maxMktSz': '12000',
'maxLmtAmt': '20000000',
'maxMktAmt': '',
'maxTwapSz': '100000000.0000000000000000',
'maxIcebergSz': '100000000.0000000000000000',
'maxTriggerSz': '100000000.0000000000000000',
'maxStopSz': '12000',
'futureSettlement': False,
'tradeQuoteCcyList': [],
'instIdCode': 10459,
}


url = "https://www.okx.com/api/v5/public/instruments?instType=FUTURES"
response = requests.get(url)
datas = response.json()
datas = datas['data']

for data in datas:
    instId = data['instId']
    instType = data['instType']
    filter_result = {}
    if "BTC-USDT" in instId:
        for key, value in spot_demo.items():
            # pass
            filter_result[key] = data[key]
        print(filter_result)
        print(data)